helpMenu = {}

local keyW, keyS, keyA, keyD, keyUp, keyDown, keyLeft, keyRight, keyEsc, keySpace

function helpMenu:init()
  --Images
  keyW = love.graphics.newImage('assets/textures/helpMenu/wKey.png')
  keyS = love.graphics.newImage('assets/textures/helpMenu/sKey.png')
  keyA = love.graphics.newImage('assets/textures/helpMenu/aKey.png')
  keyD = love.graphics.newImage('assets/textures/helpMenu/dKey.png')
  keyUp = love.graphics.newImage('assets/textures/helpMenu/up.png')

  keyDown = love.graphics.newImage('assets/textures/helpMenu/down.png')
  keyLeft = love.graphics.newImage('assets/textures/helpMenu/left.png')
  keyRight = love.graphics.newImage('assets/textures/helpMenu/right.png')
  
  keyEsc = love.graphics.newImage('assets/textures/helpMenu/escape.png')
  keySpace = love.graphics.newImage('assets/textures/helpMenu/space.png')
  
  --Used for placing images and text evenly on the screen
  offUp = 640 - 80 - hudFontSmall:getWidth("Pitch Up") - 20 - keyUp:getWidth()
  offW = offUp - 20 - keyW:getWidth()
  
  offDown = 640 + 80 + hudFontSmall:getWidth("Pitch Down") + 20
  offS = offDown + 20 + keyDown:getWidth()
  
  offLeft = 640 - 80 - hudFontSmall:getWidth("Fire Weapon") - 20 - keyA:getWidth()
  offA = offLeft - 20 - keyA:getWidth()
  
  offSpace = 0
  offEsc = offSpace + 0
  
  --Weapons/PowerUps
  empImage = love.graphics.newImage('assets/textures/Weapons/empRaw.png')
  laserImage = love.graphics.newImage('assets/textures/laser1.png')
  healthImage = love.graphics.newImage('assets/textures/PowerUps/wrenchAnim/1.png')
end

function helpMenu:enter()
end

function helpMenu:update(dt)
end

function helpMenu:draw(dt)
  --Story
  --Didn't like the line spacing of a formatted print so I did manual line prints to control line spacing better.
  love.graphics.setColor(color.red)
  love.graphics.setFont(hudFontSmall)
 --[[ love.graphics.print("The enemy is upon you! You've been separated from your troops after a long, hard battle. A battle that your forces", 100, 20)
  love.graphics.print(" lost. Now, the rebels are taking out the survivors, and they've set their sights on you. Taking refuge in a nearby", 100, 45)
  love.graphics.print(" asteroid field, you try to make your way back to base but are caught, and they spare no expensive in hunting you", 100, 70)
  love.graphics.print(" down. They've deployed many fighters, drones, and mines to destroy you, and are using high-energy beams to destroy", 100, 95)
  love.graphics.print(" the very asteroid field you are in! It's unlikely that you can make it out of this alive, but you can take as many of them", 100, 120)
  love.graphics.print(" down with you as possible!", 100, 145)]]
  love.graphics.print("The enemy is upon you! You've been separated from your troops after the arduous battle above the planet Yaxis 7. Your ", 80, 20)
  love.graphics.print("fleet has been decimated, and now the victorious Rbels are hunting the survivors. After feeling into a nearby asteroid", 80, 45)
  love.graphics.print(" field, you must now fight to survive the Rebels' endless waves of fighters, drones, and mines, as well as their high-energy", 80, 70)
  love.graphics.print(" beams that are the destroying the very asteroid field you're hiding in! Destroy the rebels. Survive the onslaught. Avenge", 80, 95)
  love.graphics.print(" your fallen fleet!", 80, 120)
  --Controls
  --Text
  love.graphics.setColor(color.white)
  love.graphics.setFont(hudFontSmall)
  love.graphics.print("Pitch Up", 640 - 80 - hudFontSmall:getWidth("Pitch Up"), 250)
  love.graphics.print("Pitch Down", 640 + 80, 250)
  love.graphics.print("Select EMP", 640 - 80 - hudFontSmall:getWidth("Pitch Up"), 320)
  love.graphics.print("Select lasers", 640 + 63, 320)
  love.graphics.print("Fire Weapon", 640 - 80 - hudFontSmall:getWidth("Pitch Up"), 390)
  love.graphics.print("Pause Game", 640 + 80, 390)
  
  --Images
  love.graphics.draw(keyUp, offUp, 250 - keyUp:getHeight()/4)
  love.graphics.draw(keyW, offW, 250 - keyW:getHeight()/4)
  love.graphics.draw(keyDown, offDown, 250 - keyDown:getHeight()/4)
  love.graphics.draw(keyS, offS, 250 - keyS:getHeight()/4)
  
  love.graphics.draw(keyLeft, offUp, 320 - keyLeft:getHeight()/4)
  love.graphics.draw(keyA, offW, 320 - keyA:getHeight()/4)
  love.graphics.draw(keyRight, offDown, 320 - keyRight:getHeight()/4)
  love.graphics.draw(keyD, offS, 320 - keyD:getHeight()/4)
  
  
  love.graphics.draw(keySpace, offW, 390 - keySpace:getHeight()/4)
  love.graphics.draw(keyEsc, offDown, 390 - keyEsc:getHeight()/4)
  
  
  --EMP 
  --Image
  love.graphics.draw(empImage, game.window.width*0.2, 500)
  --Description
  love.graphics.print("EMP: Drops behind you and", game.window.width*0.2 - hudFontSmall:getWidth("EMP: Drops behind you and")/2, 525)
  love.graphics.setColor(64, 128, 255, 255)
  love.graphics.print("EMP:",game.window.width*0.2 - hudFontSmall:getWidth("EMP: Drops behind you and")/2, 525)
  love.graphics.setColor(color.white)
  love.graphics.print("temporarily disables enemy ships.",game.window.width*0.2 - hudFontSmall:getWidth("temporarily disables enemy ships.")/2, 550)
   
  --Laser
  --Image
  love.graphics.draw(laserImage, game.window.width*0.8, 505)
  --Description
    love.graphics.print("Laser: Fires in front of you", game.window.width*0.8 - hudFontSmall:getWidth("Laser: Fires in front of you")/2, 525)
  love.graphics.setColor(color.green)
  love.graphics.print("Laser:", game.window.width*0.8 - hudFontSmall:getWidth("Laser: Fires in front of you")/2, 525)
  love.graphics.setColor(color.white)
  love.graphics.print("destroys enemy ships and mines.", game.window.width*0.8 - hudFontSmall:getWidth("destroys enemy ships and mines.")/2, 550)
  
  --HealthUp
  --Image
  love.graphics.draw(healthImage, game.window.width*0.5 - 20, 460, 0, 0.35, 0.35)
  --Description
  love.graphics.print("Wrench: Repairs ship.", game.window.width*0.5 - hudFontSmall:getWidth("Wrench: Repairs ship.")/2, 525)
  love.graphics.setColor(180,180,180,255)
  love.graphics.print("Wrench:", game.window.width*0.5 - hudFontSmall:getWidth("Wrench: Repairs ship.")/2, 525)
  
  --Exit
  love.graphics.setColor(color.green)
  love.graphics.setFont(hudFontLarge)
  love.graphics.print("Exit",  640 - hudFontLarge:getWidth("Exit")/2, 720 - 20 - hudFontLarge:getHeight("Exit"))
  
  --Mute Audio
  love.graphics.setFont(hudFontSmall)
  love.graphics.setColor(color.red)
  love.graphics.print("[M]ute Audio", 1280-20-hudFontSmall:getWidth("[M]ute Audio"), 720 - 20 - hudFontSmall:getHeight("[M]ute Audio"))
  --Fullscreen
  love.graphics.print("[F]ullscreen", 20, 720-20-hudFontSmall:getHeight("[F]ullscreen"))
end

function helpMenu:leave()
end

--Input
function helpMenu:keypressed(k)
  --Exit
  if k == "escape" or k == "return" then
    Gamestate.pop(helpMenu)
  end
  
  --Mute/Unmute audio
  if k == "m" then
    if love.audio.getVolume() ~= 1 then
      love.audio.setVolume(1)
    else
      love.audio.setVolume(0)
    end
  end
  
  --Fullscreen
  if k == 'f' then
    love.graphics.toggleFullscreen()
  end
  
end
function helpMenu:keyreleased(k)
end
function helpMenu:mousepressed(x,y,b)
end
function helpMenu:mousereleased(x,y,b)
end
